package com.cms.security;

/**
 * Created by Administrator on 2018/7/31 0031.
 */
import com.cms.setting.account.pojo.LoginAccount;
import com.google.common.base.Objects;

import org.springframework.stereotype.Service;

import java.io.Serializable;

/** 
* 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息.
* @author zhoutanxin@hotmail.com  
* @date 2018年11月8日 下午11:13:59 
*  
*/
@Service
public  class LoginInfo implements Serializable {
    private static final long serialVersionUID = -1373760761780840081L;
    public Integer userId;
    public String loginEmail;
    public String userName;
    private LoginAccount loginAccount;
    public LoginInfo(Integer userId, String loginEmail, String userName) {
        this.userId = userId;
        this.loginEmail = loginEmail;
        this.userName = userName;
    }
    public LoginInfo(){}
    
    
    public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}


	public String getLoginEmail() {
		return loginEmail;
	}
	public void setLoginEmail(String loginEmail) {
		this.loginEmail = loginEmail;
	}

	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public LoginAccount getLoginAccount() {
		return loginAccount;
	}
	public void setLoginAccount(LoginAccount loginAccount) {
		this.loginAccount = loginAccount;
	}
	/**
     * 本函数输出将作为默认的<shiro:principal/>输出.
     */

    public String toString() {
        return loginEmail;
    }

    /**
     * 重载hashCode,只计算loginName;
     */

    public int hashCode() {
        return Objects.hashCode(loginEmail);
    }

    /**
     * 重载equals,只计算loginName;
     */

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        LoginInfo other = (LoginInfo) obj;
        if (loginEmail == null) {
            if (other.loginEmail != null) {
                return false;
            }
        } else if (!loginEmail.equals(other.loginEmail)) {
            return false;
        }
        return true;
    }
}
